package com.heima.comment.controller;

import com.heima.comment.dto.CommentRepayDto;
import com.heima.comment.dto.CommentRepayLikeDto;
import com.heima.comment.dto.CommentRepaySaveDto;
import com.heima.comment.service.ICommentRepayService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {

    @Autowired
    private ICommentRepayService repayService;

    /**
     * 发表回复
     * @param dto
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "saveRepay" ,notes = "发表回复")
    @ApiModelProperty(name = "dto" ,dataType = "CommentRepaySaveDto" ,required = true)
    public ResponseResult saveRepay(@RequestBody CommentRepaySaveDto dto) {
        return repayService.saveRepay(dto);
    }

    /**
     * 点赞回复
     * @param dto
     * @return
     */
    @PostMapping("/like")
    @ApiOperation(value = "like" ,notes = "点赞回复")
    @ApiModelProperty(name = "dto" ,dataType = "CommentRepayLikeDto" ,required = true)
    public ResponseResult like(@RequestBody CommentRepayLikeDto dto){
        return repayService.like(dto);
    }

    /**
     * 加载回复列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    @ApiOperation(value = "load" ,notes = "加载回复列表")
    @ApiModelProperty(name = "dto" ,dataType = "CommentRepayDto" ,required = true)
    public ResponseResult load(@RequestBody CommentRepayDto dto){
        return repayService.load(dto);
    }
}